<!DOCTYPE html>
<!-- saved from url=(0052)http://getbootstrap.com/docs/4.0/examples/dashboard/ -->
<html lang="en">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<meta name="description" content="">
		<meta name="author" content="">

		<title>Dashboard Template for Bootstrap</title>
		<!-- Bootstrap core CSS -->
		<link href="../asserts/css/bootstrap.min.css" rel="stylesheet">

		<!-- Custom styles for this template -->
		<link href="../asserts/css/dashboard.css" rel="stylesheet">
		<link rel="stylesheet" href="../asserts/css/style.css" >
		<script type="text/javascript" src="../asserts/js/xlsx.core.min.js" ></script>
		<style type="text/css">
			/* Chart.js */
			
			@-webkit-keyframes chartjs-render-animation {
				from {
					opacity: 0.99
				}
				to {
					opacity: 1
				}
			}
			
			@keyframes chartjs-render-animation {
				from {
					opacity: 0.99
				}
				to {
					opacity: 1
				}
			}
			
			.chartjs-render-monitor {
				-webkit-animation: chartjs-render-animation 0.001s;
				animation: chartjs-render-animation 0.001s;
			}
		</style>
	</head>

	<body>
		<nav class="navbar navbar-dark sticky-top bg-dark flex-md-nowrap p-0">
			<a class="navbar-brand col-sm-3 col-md-2 mr-0" href="http://getbootstrap.com/docs/4.0/examples/dashboard/#">Company name</a>
			<input class="form-control form-control-dark w-100" type="text" placeholder="Search" aria-label="Search">
			<ul class="navbar-nav px-3">
				<li class="nav-item text-nowrap">
					<a class="nav-link" href="http://getbootstrap.com/docs/4.0/examples/dashboard/#">Sign out</a>
				</li>
			</ul>
		</nav>

		<div class="container-fluid">
			<div class="row">
				<nav class="col-md-2 d-none d-md-block bg-light sidebar">
					<div class="sidebar-sticky">
						<ul class="nav flex-column">
							<li class="nav-item">
								<a class="nav-link active" href="dashboard.html">
									<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-home">
										<path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path>
										<polyline points="9 22 9 12 15 12 15 22"></polyline>
									</svg>
									文件管理 <span class="sr-only">(current)</span>
								</a>
							</li>

						</ul>
					</div>
				</nav>
				<main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">

					<h1>考研数据分析平台</h1>
					<h4>请上传需要分析的EXCEL文件</h4>

					<form id="formId">
						<div class="container">
							<div class="form-group">
								<input type="file" name="file" class="file">
								<div class="input-group col-xs-12">
									<span class="input-group-addon"><i class="glyphicon glyphicon-upload"></i></span>
									<input type="text" class="form-control input-lg" disabled placeholder="Upload Excel" id="inputId">
									<span class="input-group-btn">
                                <button class="browse btn btn-primary input-lg" type="button"><i class="glyphicon glyphicon-search"></i> Browse</button>
                            </span>
								</div>
							</div>
							<button type="button" class="btn btn-primary" id="submitBtn" >添加</button>
						</div>

					</form>
				</main>


			</div>
		</div>

		<!-- Bootstrap core JavaScript
    ================================================== -->
		<!-- Placed at the end of the document so the pages load faster -->
		<script type="text/javascript" src="../asserts/js/popper.min.js" ></script>
		<!-- Icons -->
		<script type="text/javascript" src="../asserts/js/feather.min.js" ></script>
		<script>
			feather.replace()
		</script>

	<!--<script>-->
        <!--//删除当前 员工-->
        <!--// $(".deleteBtn").click(function () {-->
        <!--//     if (confirm("确定删除文件吗？")) {-->
        <!--//         $("#deleteEmpFrom").attr("action", $(this).attr("del_uri")).submit();-->
        <!--//     }-->
        <!--// })-->
	<!--</script>-->

		<script src='../asserts/js/jquery.min.js'></script>

		<script type="text/javascript" src='../asserts/js/bootstrap.min.js'></script>
		<script type="text/javascript" src="../asserts/js/index.js"></script>

		<script>
            $(function () {
                $("#submitBtn").click(function () {
                    if ($("#inputId").val() == ""){
                        alert("文件不能为空")
                        return ;
                    }else {
                        var data = new FormData($("#formId")[0]);//获取表单中的文件
                        $.ajax({
                            type: "POST",
                            dataType: "json",//返回的数据类型
                            url: "/postgraduate/files",
                            data: data,
                            contentType: false,//jQuery中contentType默认为application/x-www-form-urlencoded，因此传入的data会被转为默认的HTTP编码，这里我们不需要这种转换，设置为false。
                            processData: false,//jQuery会将传入的data对象转为字符串来发送HTTP请求，这里我们的data已经是FormData对象处理好的multipart/form-data编码，所以不需要转换，设置为false。
                            success: function(res){
                                console.log(res)
                                if (res.code == 200){
                                    window.location.href = "./dashboard.html"
                                } else{
                                    alert("文件商户上传失败")
                                    return
                                }
                            },
                            error:function () {
                                alert("服务器内部错误");
                            }
                        });
                    }
                });
            });
		</script>

	</body>

</html>